import Vue from "vue"
import Vuex from "vuex"
import mutations from "./mutations"
import actions from "./actions"
import getters from "./getters"
import moduleA from "./mutations/moduleA"

// import {INCREMENT} from "./mutations_type"
// 1.安装插件
Vue.use(Vuex)

// 2.创建对象

const state = {
        counter:1000,
        students:[
            {id:110,name:'why1',age:18},
            {id:111,name:'why2',age:24},
            {id:112,name:'why3',age:30},
            {id:113,name:'why4',age:10}
        ],
        info:{
            name:'kobe',
            age:40,
            height:1.98
        }
}
const store = new Vuex.Store({
    // 保存状态的
    // state单一状态树
    // 只有提前加入响应式系统的才会响应式
    state,
    // 状态更新
    mutations,
    // 异步操作
    actions,
    // 类似于vue的计算属性
    getters,
    // 划分模块
    modules:{
        a:moduleA,
        
    }
})

// 3.导出store对象
export default store

// 对象的解构
// const obj = {
//     name:'why',
//     age:18,
//     height:1.88
// }
// // 顺利不影响
// const {name,age,height} = obj
// console.log(obj.name)